#include <iostream>
#include <set>
using namespace std;
void test(){
   int n,m;
   cin >> n >> m;
   set <int> union_set;
   for(int i =0;i<n;i++){
       int num;
       cin >> num;
       union_set.insert(num);
   }
   for(int i = 0;i<m;i++){
       int num;
       cin >> num;
       union_set.insert(num);
   }

   for(auto & num : union_set){
       cout << num << " ";
   }
   cout << endl;
}
int main()
{
    test();
    return 0;
}

